package models

type Comment struct {
	ID        int      `json:"id" gorm:"column:id;->"`
	UserID    int      `json:"-" gorm:"column:user_id;"`
	CourseID  int      `json:"course_id" validate:"required,gte=1" gorm:"column:course_id;"`
	Score     int      `json:"score" gorm:"column:score;"`
	Content   string   `json:"content" validate:"min=1,max=255" gorm:"column:content;"`
	CreatedAt JSONTime `json:"created_at" validate:"-" gorm:"column:created_at;type:datetime"`
}

type CommentWithUser struct {
	Comment
	User User `json:"user" gorm:"foreignKey:UserID;" validate:"-"`
}

// 实现 TableName 方法指定表名
func (CommentWithUser) TableName() string {
	return "comments"
}
